/* -------------------- 显示隐藏 --------------------*/
(function () {
    const user = $(".user");
    const user_menu_wrapper = $(".user-menu-wrapper");

    user.hover(function () {
        user_menu_wrapper.stop().slideToggle();
    // }, function () {
    //     user_menu_wrapper.stop().slideUp();
    })
})();

/* ---------- 显示隐藏二维码 ---------- */
(function () {
    const wx = document.querySelector('.wx');
    const pvg = document.querySelector('#wx');
    wx.onmouseenter = function () {
        pvg.style.display = 'block';
    }
    wx.onmouseleave = function() {
        pvg.style.display = 'none';
    }
})();

/* ---------- 购物车fixed ---------- */
$(document).on("resize scroll", function () {
    function fixed() {
        let cart_list = $(".cart-goods-list");
        let cart_bar = $(".cart-bar");

        let con_Height = cart_list.offset().top + cart_list.outerHeight() + cart_bar.outerHeight() - $(window).height();
    
        if (con_Height >= $(document).scrollTop()) {
            cart_bar.addClass("cart-bar-fixed");
        } else {
            cart_bar.removeClass("cart-bar-fixed");
        }
    }
    fixed();
})

// /* ----------- 页面的登录守卫 --------- */
// if (localStorage.getItem("state") !== "ok") {
//     location.href = "../html/Login.html";
// }